# Contributor: rubicon <rubicon@mailo.com>
# Maintainer:
pkgname=ocaml-alcotest
_pkgname=alcotest-js
pkgver=1.5.0
pkgrel=0
pkgdesc="Lightweight and colourful test framework"
url="https://github.com/mirage/alcotest"
arch="all !riscv64" # restricted by ocaml
license="ISC"
depends="ocaml-runtime"
depends_dev="$pkgname=$pkgver-r$pkgrel"
makedepends="
	dune
	ocaml
	ocaml-astring-dev
	ocaml-cmdliner-dev
	ocaml-findlib
	ocaml-fmt-dev
	ocaml-logs-dev
	ocaml-re-dev
	ocaml-seq-dev
	ocaml-stdlib-shims
	ocaml-uutf-dev
	ocaml-lwt-dev
	ocaml-ocplib-endian-dev
	ocaml-mmap-dev
	ocaml-bigarray-compat-dev
	"
options="!check"
checkdepends="ocaml-result-dev"
provides="$pkgname-lwt=$pkgver-r$pkgrel"
subpackages="$pkgname-dev"
source="$pkgname-$pkgver.tar.bz2::https://github.com/mirage/alcotest/releases/download/$pkgver/alcotest-js-$pkgver.tbz"
builddir="$srcdir/$_pkgname-$pkgver"

# 32-bit archs
case "$CARCH" in
	arm*|x86) options="$options textrels" ;;
esac

build() {
	export OCAMLPATH=/usr/lib/ocaml
	dune build \
		-p alcotest,alcotest-lwt \
		@install --no-buffer --verbose
}

check() {
	dune runtest --no-buffer --verbose
}

package() {
	dune install \
		--destdir="$pkgdir" \
		--prefix=/usr \
		--libdir=/usr/lib/ocaml \
		alcotest alcotest-lwt

	rm -Rf "$pkgdir"/usr/doc
}

dev() {
	default_dev
	provides="$pkgname-lwt-dev=$pkgver-r$pkgrel"

	cd "$pkgdir"

	local path; for path in $(find usr/lib/ocaml \( \
			-name '*.cmt' -o \
			-name '*.cmti' -o \
			-name '*.cmx' -o \
			-name '*.cmxa' -o \
			-name '*.ml' -o \
			-name '*.mli' \
		\))
	do
		amove "$path"
	done
}

sha512sums="
1aea91de40795ec4f6603d510107e4b663c1a94bd223f162ad231316d8595e9e098cabbe28a46bdcb588942f3d103d8377373d533bcc7413ba3868a577469b45  ocaml-alcotest-1.5.0.tar.bz2
"
